<template>
  <div id="editor"></div>
</template>

<script>
import Editor from 'wangeditor'
export default {
data() {
 return{
  editor:null
 }
},
props:{
  editorContent:{
    require:true,
    type:Object
  }
},
methods:{
 initEditor() {
  this.editor = new Editor ('#editor')
  this.editor.config.uploadImgShowBase64 = true   // 使用 base64 保存图片
  this.editor.create();
  this.editor.txt.html(this.editorContent.content);
  this.$eventBus.$on('submit',()=>{
    this.editorContent.content = this.editor.txt.html()
  })
}
},
mounted(){
  this.initEditor();
}
}
</script>

<style scoped>
#editor{
  width:100%;
  height:400px;
}
</style>